package com.anysoft.utils.login;

import javax.crypto.SecretKey;

public class PBKDF2_Utils {


    public static SecretKey deriveKey(String password, byte[] salt) {
        return Crypto.deriveKeyPbkdf2(salt, password);
    }

    public static String getRawKey(byte[] salt, String password) {
        SecretKey key = deriveKey(password, salt);
        if (key == null) {
            return null;
        }

        return Crypto.toHex(key.getEncoded());
    }

    public static byte[] getSalt() {
        return Crypto.generateSalt();
    }

}
